// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui';

import router from './router/routerConfig'
import store from './vuex/store.js'


//拦截接口、模拟数据
import axios from './axios/axiosConfig'
import VueAxios from 'vue-axios'
import "babel-polyfill"
// domain
import * as api from './axios/api.js'
window.api = api;
// 项目全局组件注册引入
import '@/vue-component.js'
// vuetable所需组件引入
import '@/vue-table-component.js'
import '../static/css/iconfont.css'


import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.config.productionTip = false;
Vue.use(VueAxios, axios)
Vue.use(ElementUI)


new Vue({
    el: '#app',
    router,
    store,
    template: '<App/>',
    components: { App }
})


// 权限验证   modular :  模块名称；  type：  操作类型  v-has = "user:add";
Vue.directive('has', {
    bind: function (el, binding) {
        let authorizationData = localStorage.getItem('authorizationData');
        let flag = authorizationData.indexOf(binding.value);
        if(flag == -1){
            if(binding.arg == 'table'){
                $(el).empty();
            }else{
                console.log(el);
                el.parentNode.removeChild(el);
            }
        }
    }
});
Vue.prototype.hasPermission  = function(str) {
    let authorizationData = localStorage.getItem('authorizationData');
    let flag = authorizationData.indexOf(str);
    if(flag == -1){
        return false
    }else{
        return true
    }
}